#!/bin/bash

finish() {
    echo '\n🍺   完成'
    exit 0
}

getInfo() {
  info=$1
  yn=$2
  if [ $yn ]; then
    read -p "${info}[y/n]?" -n 1 result
    echo $result
  else
    read -p "${info}" result
    echo $result
  fi
}

goNext=`getInfo '此脚本用于初始化 iOS 代理机环境，请使用管理员账号运行，确定要继续执行' true`

if [ $goNext != 'y' ]; then
finish
fi

sudo systemsetup -setremotelogin on

if [ ! -n `which brew` ]; then
  /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi

if [ ! -n `which pod` ]; then
brew install pod
if [ $? != 0  ]
then
    echo '请手动安装pod后重新执行该脚本'
    exit 1
fi
fi
finish
